import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * Simple client program wihch gets the string from the server.
 * @author imnak0
 *
 */
public class AdviceClient {
	private final String TAG = "AdviceClient";
	
	public void go() {
		System.out.println(TAG + ": start client");
		
		try {
			Socket socket = new Socket("imnak0.cafe24.com", 2121);
			
			InputStreamReader streamReader = new InputStreamReader(socket.getInputStream());
			BufferedReader reader = new BufferedReader(streamReader);
			
			String advice = reader.readLine();
			System.out.println(TAG + ": The advice of the day is : " + advice);
			
			reader.close();
		} catch (IOException e) {
			System.out.println(TAG + ": IOException occured");
			e.printStackTrace();
		}
		
		System.out.println(TAG + ": finish client");
	}
	
	public static void main(String[] args) {
		AdviceClient client = new AdviceClient();
		client.go();
	}
}
